﻿/* Author: Achim Schnell */

namespace AppFx.Tokenization
{
    /// <summary>
    /// Verifies a string/char for a token.
    /// </summary>
    public interface IVerifier
    {
        #region Properties

        /// <summary>
        /// The parent tokenizer of a verifier.
        /// </summary>
        ITokenizer Tokenizer { get; }

        #endregion

        #region Methods

        /// <summary>
        /// Detects if the given char matches the token's pattern.
        /// </summary>
        /// <param name="c">Char to verify for tokenization.</param>
        /// <returns>A bool indicating if the given char matches the token's pattern.</returns>
        bool Verify(char c);

        /// <summary>
        /// Saves a given char in the verifiers string to create a token.
        /// </summary>
        /// <param name="c">The char to consume.</param>
        /// <returns></returns>
        void Consume(char c);

        /// <summary>
        /// Resets the verifiers buffer.
        /// </summary>
        void Reset();

        /// <summary>
        /// Finalizes the current input-pattern returning a token.
        /// </summary>
        /// <remarks>
        /// Resets the Verifiers buffer.
        /// </remarks>
        /// <returns>An IToken containing the current input-pattern.</returns>
        IToken Finalize();

        #endregion
    }
}
